lib/repo-pull: Support retries for delta superblocks
authorPhilip Withnall <withnall@endlessm.com>
Mon, 28 May 2018 16:06:46 +0000 (17:06 +0100)
committerAtomic Bot <atomic-devel@projectatomic.io>
Wed, 30 May 2018 19:57:13 +0000 (19:57 +0000)
Use the recently introduced architecture for retrying network requests
on transient failure to do the same for delta superblock requests, now
that they’re queued.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
Closes: #1600
Approved by: jlebon

src/libostree/ostree-repo-pull.c

index 7d05c10f282a2da22c6a55a61e1eee3921b3eb68..550a33de7b87579269e1df65db81e81ca4a1015f 100644 (file)
@@ -212,6 +212,7 @@ typedef struct {
   char *from_revision;
   char *to_revision;
   OstreeCollectionRef *requested_ref;  /* (nullable) */
+  guint n_retries_remaining;
 } FetchDeltaSuperData;
 
 static void
@@ -2767,8 +2768,10 @@ on_superblock_fetched (GObject   *src,
   if (local_error == NULL)
     pull_data->n_fetched_metadata++;
 
-  /* FIXME: This should check _ostree_fetcher_should_retry_request(). */
-  check_outstanding_requests_handle_error (pull_data, &local_error);
+  if (_ostree_fetcher_should_retry_request (local_error, fetch_data->n_retries_remaining--))
+    enqueue_one_static_delta_superblock_request_s (pull_data, g_steal_pointer (&fetch_data));
+  else
+    check_outstanding_requests_handle_error (pull_data, &local_error);
 
   g_clear_pointer (&fetch_data, fetch_delta_super_data_free);
 }
@@ -2822,6 +2825,7 @@ enqueue_one_static_delta_superblock_request (OtPullData                *pull_dat
   fdata->from_revision = g_strdup (from_revision);
   fdata->to_revision = g_strdup (to_revision);
   fdata->requested_ref = (ref != NULL) ? ostree_collection_ref_dup (ref) : NULL;
+  fdata->n_retries_remaining = pull_data->n_network_retries;
 
   enqueue_one_static_delta_superblock_request_s (pull_data, g_steal_pointer (&fdata));
 }